/**
 * Created by 001 on 2017/9/12.
 */
/*弹出框*/
var PopView = Vue.extend({
    props: ['question'],
    template: '<div id="mask">\n' +
    '        <div id="popup-frame">\n' +
    '            <h6>{{question}}</h6>\n' +
    '            <div class="frameBtn clearfix">\n' +
    '                <span @click="accept">取消</span>\n' +
    '                <span @click="deny">确定</span>\n' +
    '            </div>\n' +
    '        </div>\n' +
    '    </div>',
    data: function () {
        return {}
    },
    methods: {
        accept: function () {
            this.$emit('on');
        },
        deny: function () {
            this.$emit('ok');
        }
    }
});

/*提示框*/
var PromptView = Vue.extend({
    template: '<div id="prompt-view">' +
    '<transition name="fade">' +
    '<template v-if="showMessage">' +
    '<div id="message">' +
    '<span>{{message}}</span>' +
    '</div>' +
    '</template>' +
    '</transition>' +
    '</div>',
    data: function () {
        return {
            showMessage: false,
            message: ""
        }
    },
    created: function () {
    },
    methods: {
        /*提示信息*/
        toast: function (message) {
            //var is_weixin = (function(){return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1})();
            if (window.webkit && window.webkit.messageHandlers) { // iphone
                window.webkit.messageHandlers.jsShowToast.postMessage(message);
                return;
            } else if (window.android && window.android.jsShowToast) {
                window.android.jsShowToast(message);
                return;
            }
            this.message = message
            this.showMessage = true
            var that = this
            setTimeout(function () {
                that.showMessage = false
            }, 1000)
        },
        toastInWechat: function (message) {
            this.message = message
            this.showMessage = true
            var that = this
            setTimeout(function () {
                that.showMessage = false
            }, 1000)
        }
    }
});

/*页面加载loading*/
var LoadingView = Vue.extend({
    template: '<div id="loading-view">' +
    '<div id="mask" class="trans-back">' +
    '<img src="/imgs/course/loading.gif" class="loading">' +
    '</div>' +
    '</div>',
    data: function () {
        return {}
    },
    methods: {}
});
//全局注册组件
Vue.component('prompt-view', PromptView);
Vue.component('pop-view', PopView);
Vue.component('loading-view', LoadingView);